package com.vogue.supplymall.shop.domain.dao.impl;

import com.vogue.supplymall.shop.domain.dao.OrganShopImgDao;
import com.vogue.supplymall.shop.domain.mapper.OrganShopImgMapper;
import com.vogue.supplymall.shop.domain.model.OrganShopImg;
import org.springframework.stereotype.Repository;

import javax.annotation.Resource;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * The type Organ shop img dao.
 *
 * @Aouthor: zhangliang
 * @Date: Create in 2017-12-12
 */
@Repository("organShopImgDao")
public class OrganShopImgDaoImpl extends BaseDaoImpl<OrganShopImg, Long> implements OrganShopImgDao {

    @Resource
    private OrganShopImgMapper organShopImgMapper;

    @Override
    public List<OrganShopImg> findBySysCode(Long sysCode, Long organid) {
        return organShopImgMapper.findBySysCode(sysCode, organid);
    }

	@Override
	public List<OrganShopImg> findEntImgBySysCode(Long sysCodeId) {
		
		return organShopImgMapper.findEntImgBySysCode(sysCodeId);
	}

    @Override
    public String getImgUrl4Comment(String shopid) {
        Map<String, Object> map = new HashMap<>();
        map.put("shopid", shopid);
        StringBuilder sql = new StringBuilder();
        sql.append(" SELECT i.imgurl from organ_shop_img i, shop s where i.organid = s.organid and s.id = #{shopid}");
        List<Map<String, Object>> list = this.query0(sql.toString(),map);

        if (list != null && list.size() > 0) {
            return list.get(0).get("imgurl").toString();
        }
        return null;
    }

}
